package com.fanrenqiji.modules.business.dict.dao;



import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.modules.business.dict.entity.BusDict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lijian E-mail:ljz0721cx@163.com
 * @version 创建时间：2015年1月22日 上午11:44:12
 * @description 数据字典表 记录系统的数据词
 */
public interface BusDictDao extends BusDictDaoCustom, CrudRepository<BusDict, Long> {

	@Query("from BusDict where delFlag='" + BusDict.DEL_FLAG_NORMAL + "' order by sort")
	public List<BusDict> findAllList();

	@Query("select type from BusDict where delFlag='" + BusDict.DEL_FLAG_NORMAL + "' group by type")
	public List<String> findTypeList();

	@Query("from BusDict where delFlag='" + BusDict.DEL_FLAG_NORMAL + "' and type =?1 order by sort")
	public List<BusDict> findBusDicsByType(String type);
	
	@Query("from BusDict where delFlag='" + BusDict.DEL_FLAG_NORMAL + "' and type =?1  and value =?2 ")
	public BusDict findBusDicsByTypeAndValue(String type, String value);

	@Modifying
	@Query("update BusDict set delFlag='" + BusDict.DEL_FLAG_DELETE + "' where id = ?1 ")
	void deleteById(Long id);

}


interface BusDictDaoCustom extends BaseDao<BusDict> {
}

@Repository
class BusDictDaoImpl extends BaseDaoImpl<BusDict> implements BusDictDaoCustom {

}
